package com.anolesoft.amljmes.billing.dto;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.fastjson.JSON;
import com.anolesoft.yr.mbus.prod.base.entity.ProdBaseServiceValue;
import com.anolesoft.yr.mbus.prod.model.entity.ProdService;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 开单信息导出DTO
 * @author 韩峰
 *
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AmBillingInfoExportDTO {
	@ExcelIgnore
	private String objuid;//主键
	@ExcelProperty("制造记录条码")
	private String pacrNo;//制造记录条码
	@ExcelProperty("机型")
	private String aircraftType;//机型
	@ExcelProperty("零件图号")
	private String partDrawingNo;//零件图号
	@ExcelProperty("零件名称")
	private String partName;//零件名称
	@ExcelProperty("派工号")
	private String dispatchNo;//派工号
	@ExcelProperty("数量(当前工序加工数量)")
	private String quantity;//数量
	@ExcelIgnore
	private String handoverCategory;//移交类别
	@ExcelProperty("移交类别")
	private String handoverCategoryName;//移交类别
	@ExcelIgnore
	private String workshopName;//外表车间
	@ExcelProperty("外表车间")
	private String workshopNameName;//外表车间
	@ExcelIgnore
	private String billingUser;//开单人
	@ExcelProperty("开单人")
	private String billingUserName;//开单人
	@ExcelIgnore
	private String billingDeft;//开单部门
	@ExcelProperty("开单部门")
	private String billingDeftName;//开单部门
	@ExcelProperty("开单时间")
	@DateTimeFormat("yyyy-MM-dd")
	private LocalDateTime billingTime;//开单时间
	@ExcelIgnore
	private String receiveUser;//接收人
	@ExcelProperty("接收人")
	private String receiveUserName;
	@ExcelIgnore
	private String receiveDept;//接收部门
	@ExcelProperty("接收部门")
	private String receiveDeptName;//接收部门
	@ExcelProperty("接收时间")
	@DateTimeFormat("yyyy-MM-dd")
	private LocalDateTime receiveTime;//接收时间
	@ExcelProperty("接收备注")
	private String receiveNotes;//接收备注
	@ExcelProperty(value = "接收状态",converter = ReceiveStateConverter.class)
	private String receiveState;//接收状态
	@ExcelIgnore
	private String factoryId;//厂代号
	@ExcelProperty("拒绝原因")
	private String refuseReason;//拒绝原因
	@ExcelIgnore
	private Integer queryType;//查询类别
	@ExcelIgnore
	private String cUser;//创建人
	@ExcelIgnore
	private LocalDateTime cTime;//创建时间
	@ExcelIgnore
	private String mUser;//修改人
	@ExcelIgnore
	private LocalDateTime mTime;//修改时间
	//private String currNum;//当前工序加工数量
	@ExcelProperty("当前工序号")
	private String currentProcessNo;//
	@ExcelProperty("当前工序名")
	private String currentProcessName;//
	@ExcelProperty("炉批号")
	private String lupihao;

	public static class ReceiveStateConverter implements Converter<String> {

		@Override
		public Class supportJavaTypeKey() {
			return null;
		}

		@Override
		public CellDataTypeEnum supportExcelTypeKey() {
			return null;
		}

		@Override
		public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
			return "";
		}

		@Override
		public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
			if(value == null){
				return new CellData("");
			}else{
				if("0".equalsIgnoreCase(value) ){
					return new CellData("已开单");
				}else if("5".equalsIgnoreCase(value) ){
					return new CellData("已撤回");
				}else if("10".equalsIgnoreCase(value) ){
					return new CellData("已接收");
				}else{
					return new CellData("已拒绝");
				}
			}
//			return null;
		}
	}
	public static void main(String[] args) {
		List<AmBillingInfoExportDTO> amBillingInfoDTOs = new ArrayList<>();
		
		for (int i = 0; i < 3; i++) {
			AmBillingInfoExportDTO amBillingInfoDTO = new AmBillingInfoExportDTO();
			amBillingInfoDTO.setPacrNo(""+i+"");
			amBillingInfoDTOs.add(amBillingInfoDTO);
		}

//		amBilingCondition.setBillingTime(LocalDateTime.now());
//		amBilingCondition.setBillingTime2(LocalDateTime.now().plusDays(1));
		System.out.println(">>>>:"+JSON.toJSONString(amBillingInfoDTOs));
	}
}
